<template>
  <a-card title="预警信息" class="card">
    <div v-if="formModel.listData.length !== 0" class="content">
      <div v-for="item in formModel.listData" :key="item.id" class="cellOut">
        <div class="title">
          <icon-svg class="icon-lightning" icon-class="icon-yujing" />
          <div class="interior">{{ item.title }}</div>
        </div>
        <div class="right">{{ item.content }}</div>
      </div>
      <div class="unfold">展开查看更多<icon-double-down /></div>
    </div>
    <div v-else>
      <a-empty />
    </div>
  </a-card>
</template>

<script lang="ts" setup>
  import { ref, reactive } from 'vue';
  import { pullWarningPageList, messageList } from '@/api/flow';
  import useLoading from '@/hooks/loading';

  const list = () => {
    return {
      listData: [] as messageList[],
    };
  };
  const formModel = ref(list());
  const { loading, setLoading } = useLoading();
  const pagination = reactive({
    page: 1,
    rows: 20,
    total: 0,
  });
  const fetchData = async (
    params = {
      ...pagination,
    }
  ) => {
    setLoading(true);
    try {
      const { data } = await pullWarningPageList(params);
      formModel.value.listData = data.rows;
      //   pagination.total = data.total;
    } catch (err) {
      // you can report use errorHandler or other
    } finally {
      setLoading(false);
    }
  };
  fetchData();
</script>

<style lang="less" scoped>
  :deep(.arco-card-header) {
    background-color: #f2f3f5;
    border: 1px solid #f2f3f5;
  }

  :deep(.arco-card-header-title) {
    font-size: 14px;
    font-weight: bold;
  }

  .card {
    border: 1px solid #f2f3f5;
  }

  .content {
    width: 100%;
  }

  .cellOut {
    display: flex;
    height: 40px;
    text-align: center;
    line-height: 40px;
    justify-content: space-between;
    background-color: #fff2ef;
    margin-bottom: 10px;
  }

  .title {
    display: flex;
    color: #333333;
    font-weight: 400;
    justify-content: flex-start;
    align-items: center;

    .interior {
      width: 60%;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }
  }

  .icon-lightning {
    width: 42px;
    font-size: 20px;
  }

  .right {
    width: 10%;
    margin-right: 17px;
    font-weight: bold;
    color: #ff4d4d;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .unfold {
    margin-top: 16px;
    position: relative;
    width: 150px;
    left: 40%;
    color: #888888;
  }
</style>
